package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PurchaseBookPicture;
import com.pgybook.db.entity.domain.PurchaseBookPictureEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PurchaseBookPictureMapper {
    int countByExample(PurchaseBookPictureEx example);

    int deleteByExample(PurchaseBookPictureEx example);

    @Delete({
            "delete from purchasebookpicture",
            "where PURCHASEBOOKPICTUREID = #{purchasebookpictureid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long purchasebookpictureid);

    @Insert({
            "insert into purchasebookpicture (PURCHASEBOOKID, ISMAINPIC, ",
            "DISPLAYSEQ, FORMAT, ",
            "STATUS, FILESIZE, ",
            "CONTENT)",
            "values (#{purchasebookid,jdbcType=BIGINT}, #{ismainpic,jdbcType=INTEGER}, ",
            "#{displayseq,jdbcType=INTEGER}, #{format,jdbcType=VARCHAR}, ",
            "#{status,jdbcType=INTEGER}, #{filesize,jdbcType=INTEGER}, ",
            "#{content,jdbcType=LONGVARBINARY})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "purchasebookpictureid", before = false, resultType = Long.class)
    int insert(PurchaseBookPicture record);

    int insertSelective(PurchaseBookPicture record);

    List<PurchaseBookPicture> selectByExampleWithBLOBs(PurchaseBookPictureEx example);

    List<PurchaseBookPicture> selectByExample(PurchaseBookPictureEx example);

    @Select({
            "select",
            "PURCHASEBOOKPICTUREID, PURCHASEBOOKID, ISMAINPIC, DISPLAYSEQ, FORMAT, STATUS, ",
            "FILESIZE, CONTENT",
            "from purchasebookpicture",
            "where PURCHASEBOOKPICTUREID = #{purchasebookpictureid,jdbcType=BIGINT}"
    })
    @ResultMap("ResultMapWithBLOBs")
    PurchaseBookPicture selectByPrimaryKey(Long purchasebookpictureid);

    int updateByExampleSelective(@Param("record") PurchaseBookPicture record, @Param("example") PurchaseBookPictureEx example);

    int updateByExampleWithBLOBs(@Param("record") PurchaseBookPicture record, @Param("example") PurchaseBookPictureEx example);

    int updateByExample(@Param("record") PurchaseBookPicture record, @Param("example") PurchaseBookPictureEx example);

    int updateByPrimaryKeySelective(PurchaseBookPicture record);

    @Update({
            "update purchasebookpicture",
            "set PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT},",
            "ISMAINPIC = #{ismainpic,jdbcType=INTEGER},",
            "DISPLAYSEQ = #{displayseq,jdbcType=INTEGER},",
            "FORMAT = #{format,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "FILESIZE = #{filesize,jdbcType=INTEGER},",
            "CONTENT = #{content,jdbcType=LONGVARBINARY}",
            "where PURCHASEBOOKPICTUREID = #{purchasebookpictureid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(PurchaseBookPicture record);

    @Update({
            "update purchasebookpicture",
            "set PURCHASEBOOKID = #{purchasebookid,jdbcType=BIGINT},",
            "ISMAINPIC = #{ismainpic,jdbcType=INTEGER},",
            "DISPLAYSEQ = #{displayseq,jdbcType=INTEGER},",
            "FORMAT = #{format,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "FILESIZE = #{filesize,jdbcType=INTEGER}",
            "where PURCHASEBOOKPICTUREID = #{purchasebookpictureid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PurchaseBookPicture record);
}
